package com.networkmanagerj.view.equipamentoStatus
{
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.events.FlexEvent;
	import mx.messaging.messages.ErrorMessage;
	import mx.messaging.messages.RemotingMessage;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;

	public class EquipamentoStatusGridScript extends EquipamentoStatusGridView
	{
		private var loadUsuarios:Boolean = true;
		private var loadGrupo:Boolean = true;
		public function EquipamentoStatusGridScript()
		{
			super();
			remoteObject.getOperation("getEquipamentoStatus").addEventListener(ResultEvent.RESULT,operationSucess);
			remoteObject.getOperation("getEquipamentoStatus").addEventListener(FaultEvent.FAULT,operationFailed);
		}
		
		override protected function onCreateComplete(event:FlexEvent):void{
			super.onCreateComplete(event);
		}
		
		override protected function loadDataProvider():void{
			dataProvider =null;
			remoteObject.getEquipamentoStatus();
		}
		
		override protected function operationSucess(event:ResultEvent):void{
			if(RemotingMessage(event.token.message).operation=="getEquipamentoStatus"){
				dataProvider = event.result as ArrayCollection;
				
			}
		}
		
		override protected function operationFailed(event:FaultEvent):void{
			Alert.show("Respondeu erro");
			if(RemotingMessage(event.token.message).operation=="getEquipamentoStatus"){
				var errorMessage:ErrorMessage = event.message as ErrorMessage;				
				Alert.show(errorMessage.rootCause.message,"Erro ao buscar status!");
			}
		}
		
	}
}